package com.xh3140.xwidget.app.button;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;

import android.os.Bundle;
import android.view.View;

import com.xh3140.xwidget.app.databinding.ActivityButtonBinding;
import com.xh3140.xwidget.button.CountdownButton;
import com.xh3140.xwidget.app.R;

public class ButtonActivity extends AppCompatActivity implements View.OnClickListener {
  private ActivityButtonBinding binding;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_button);
    initListener();
  }

  private void initListener() {
    binding.buttonLight.setOnClickListener(this);
    binding.buttonDark.setOnClickListener(this);
    binding.buttonGray.setOnClickListener(this);
    binding.buttonRed.setOnClickListener(this);
    binding.buttonGreen.setOnClickListener(this);
    binding.buttonBlue.setOnClickListener(this);
    binding.buttonCyan.setOnClickListener(this);
    binding.buttonYellow.setOnClickListener(this);
    binding.buttonPurple.setOnClickListener(this);
    binding.buttonPink.setOnClickListener(this);
    binding.buttonGold.setOnClickListener(this);
    binding.buttonOrange.setOnClickListener(this);
    binding.buttonOlive.setOnClickListener(this);
    binding.buttonBrown.setOnClickListener(this);
  }

  @Override
  public void onClick(View v) {
    if (v instanceof CountdownButton) {
      ((CountdownButton) v).startTimer();
    }
  }
}